home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / nivb / mess.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  6.2 KB  |  181 lines

  1. VERSION 2.00
  2. Begin Form MessForm 
  3.    Caption         =   "Message Services Test"
  4.    ClientHeight    =   2175
  5.    ClientLeft      =   1710
  6.    ClientTop       =   1575
  7.    ClientWidth     =   5760
  8.    Height          =   2580
  9.    Left            =   1650
  10.    LinkMode        =   1  'Source
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   2175
  13.    ScaleWidth      =   5760
  14.    Top             =   1230
  15.    Width           =   5880
  16.    Begin ComboBox ServerNameBox 
  17.       Height          =   300
  18.       Left            =   1200
  19.       TabIndex        =   7
  20.       Top             =   240
  21.       Width           =   2535
  22.    End
  23.    Begin TextBox MessageBox 
  24.       Height          =   375
  25.       Left            =   1200
  26.       TabIndex        =   1
  27.       Top             =   1680
  28.       Width           =   4455
  29.    End
  30.    Begin ListBox UserNameBox 
  31.       Height          =   810
  32.       Left            =   1200
  33.       Sorted          =   -1  'True
  34.       TabIndex        =   6
  35.       Top             =   720
  36.       Width           =   2535
  37.    End
  38.    Begin CommandButton CancelButton 
  39.       Caption         =   "Cancel"
  40.       Height          =   375
  41.       Left            =   4320
  42.       TabIndex        =   3
  43.       Top             =   720
  44.       Width           =   855
  45.    End
  46.    Begin CommandButton SendButton 
  47.       Caption         =   "Send"
  48.       Default         =   -1  'True
  49.       Height          =   375
  50.       Left            =   4320
  51.       TabIndex        =   2
  52.       Top             =   240
  53.       Width           =   855
  54.    End
  55.    Begin Label Label2 
  56.       Alignment       =   1  'Right Justify
  57.       Caption         =   "Message:"
  58.       Height          =   255
  59.       Left            =   240
  60.       TabIndex        =   4
  61.       Top             =   1680
  62.       Width           =   855
  63.    End
  64.    Begin Label Label3 
  65.       Alignment       =   1  'Right Justify
  66.       Caption         =   "User:"
  67.       Height          =   255
  68.       Left            =   600
  69.       TabIndex        =   5
  70.       Top             =   720
  71.       Width           =   495
  72.    End
  73.    Begin Label Label1 
  74.       Alignment       =   1  'Right Justify
  75.       Caption         =   "File Server:"
  76.       Height          =   255
  77.       Left            =   0
  78.       TabIndex        =   0
  79.       Top             =   240
  80.       Width           =   1095
  81.    End
  82. Dim conns(MAX_CONNS) As Long
  83. Dim results As String * MAX_CONNS
  84. Sub Form_Unload (Cancel As Integer)
  85.     SetPreferredConnectionID (originalPrefConnID%)
  86. End Sub
  87. Sub SendButton_Click ()
  88.     Static results(MAX_CONNS) As Integer
  89.     ccode% = GetConnectionID(ServerNameBox.Text, connID%)
  90.     If (ccode% <> SUCCESSFUL) Then
  91.         MsgBox "Unable to get connection ID of server " + prefServer$, MB_OK, "Error"
  92.     Else
  93.         SetPreferredConnectionID (connID%)
  94.         userName$ = UserNameBox.Text
  95.         If (Len(userName$) > 0) Then
  96.             userName$ = Left$(userName$, InStr(userName$, " ") - 1)
  97.             msgText$ = MessageBox.Text
  98.             connNum& = Val(Mid$(UserNameBox.Text, InStr(UserNameBox.Text, "[") + 1))
  99.             ccode% = SendBroadcastMessage(msgText$, connNum&, results(0), 1)
  100.             If (ccode% <> SUCCESSFUL) Then
  101.                 MsgBox "Unable to send message to user " + userName$, MB_OK, "Error"
  102.             Else
  103.                 Select Case (results(0) And &HFF)
  104.                     Case &H0
  105.                         MsgBox "Message sent to user " + userName$, MB_OK, "Message Sent"
  106.                     Case &HFC
  107.                         MsgBox userName$ + "'s message buffer is full", MB_OK, "Warning"
  108.                     Case &HFD
  109.                         MsgBox "Invalid connection number", MB_OK, "Error"
  110.                     Case &HFF
  111.                         MsgBox "User " + userName$ + " is blocking messages", MB_OK, "Warning"
  112.                     Case Else
  113.                         MsgBox "Unknown error while sending message", MB_OK, "Error"
  114.                 End Select
  115.             End If
  116.         End If
  117.     End If
  118. End Sub
  119. Sub ServerNameBox_Change ()
  120.     UpdateUserNameList
  121.     SetMessageBoxText
  122. End Sub
  123. Sub ServerNameBox_Click ()
  124.     UpdateUserNameList
  125.     SetMessageBoxText
  126. End Sub
  127. Sub SetMessageBoxText ()
  128.     Dim logTime As DATE_AND_TIME
  129.     Dim oName As String * 48
  130.     connNum& = GetConnectionNumber()
  131.     ccode% = GetConnectionInformation(connNum&, oName, oType%, oID&, logTime)
  132.     If (ccode% <> SUCCESSFUL) Then
  133.         MsgBox "Unable to get user name for your connection", MB_OK, "Error"
  134.     Else
  135.         msgText$ = Left$(oName, InStr(oName, Chr$(0)) - 1)
  136.         msgText$ = msgText$ + " [" + Format$(connNum&) + "]" + ":"
  137.         MessageBox.Text = msgText$
  138.     End If
  139. End Sub
  140. Sub UpdateUserNameList ()
  141.     Dim oName As String * 48
  142.     Dim serverInfo As FILE_SERV_INFO
  143.     Dim logTime As DATE_AND_TIME
  144.     ccode% = GetConnectionID(ServerNameBox.Text, connID%)
  145.     If (ccode% <> SUCCESSFUL) Then
  146.         MsgBox "Unable to get connection ID of user " + UserNameBox.Text, MB_OK, "Error"
  147.     Else
  148.         SetPreferredConnectionID (connID%)
  149.         UserNameBox.Clear
  150.         ccode% = GetServerInformation(54, serverInfo)
  151.         If (ccode% <> SUCCESSFUL) Then
  152.             MsgBox "Unable to get number of users supported from default file server", MB_OK, "Error"
  153.         Else
  154.             For conn& = 1 To (serverInfo.maxConnectionsSupported And 255)
  155.                 ccode% = GetConnectionInformation(conn&, oName, oType%, oID&, logTime)
  156.                 If ((ccode% = SUCCESSFUL) And (oType% = OT_USER)) Then
  157.                     temp$ = Left$(oName, (InStr(oName, Chr$(0)) - 1))
  158.                     temp$ = temp$ + " [" + Format$(conn&) + "]"
  159.                     UserNameBox.AddItem temp$
  160.                 End If
  161.             Next conn&
  162.         End If
  163.     End If
  164. End Sub
  165. Sub CancelButton_Click ()
  166.     Unload MessForm
  167. End Sub
  168. Sub Form_Load ()
  169.     Dim fileServerName As String * 48
  170.     For connID% = 1 To 8
  171.         If (IsConnectionIDInUse(connID%) = 1) Then
  172.             GetFileServerName connID%, fileServerName
  173.             ServerNameBox.AddItem fileServerName
  174.         End If
  175.     Next connID%
  176.     fileServerName = GetDefaultFileServerName()
  177.     ServerNameBox.Text = fileServerName
  178.     Call UpdateUserNameList
  179.     SetMessageBoxText
  180. End Sub
  181.